/*
 * PeluqueriaApp.java
 *
 * Created on __DATE__, __TIME__
 */

package cl.pelu.main;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.beans.PropertyVetoException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import cl.pelu.busqueda.AcercaDe;
import cl.pelu.busqueda.BusquedaCliente;
import cl.pelu.inventario.IngresoInventario;
import cl.pelu.model.bo.dvo.TablaDVO;
import cl.pelu.operacion.Boleta;
import cl.pelu.operacion.BuscarBoletaForm;
import cl.pelu.operacion.BuscarCliente;
import cl.pelu.operacion.MantenedorCliente;
import cl.pelu.operacion.MantenedorClienteForm;
import cl.pelu.operacion.MantenedorServiciosForm;
import cl.pelu.utils.PeluFacade;

/**
 *
 * @author  __USER__
 */
public class PeluqueriaApp extends javax.swing.JFrame {
	
	
	private javax.swing.JMenuItem aboutMenuItem;
	private javax.swing.JMenuItem exitMenuItem;
	private javax.swing.JMenu ayudaMenu;
	private javax.swing.JMenu inventarioMenu;
	private javax.swing.JMenuBar menuBar;
	private javax.swing.JMenuItem nuevaBoletaMenuItem;
	private javax.swing.JMenuItem buscarBoletaMenuItem;
	private javax.swing.JMenuItem mantenedorServicioMenuItem;
	private javax.swing.JMenuItem mantenedorClienteMenuItem;
	private javax.swing.JMenu peluqueriaMenu;
	
	
	public static javax.swing.JDesktopPane jDesktopPane1;
	

	public PeluqueriaApp() {
		super("Peluqueria Sonia Mella - 2013 "   );
		initComponents();
	}

	
private void initComponents() {

	
	
jDesktopPane1 = new javax.swing.JDesktopPane();
menuBar = new javax.swing.JMenuBar();
peluqueriaMenu = new javax.swing.JMenu("Peluqueria");
nuevaBoletaMenuItem = new javax.swing.JMenuItem("Nueva Boleta");
buscarBoletaMenuItem = new javax.swing.JMenuItem("Buscar Boleta");
exitMenuItem = new javax.swing.JMenuItem("Salir");
inventarioMenu = new javax.swing.JMenu("Mantenedor");
mantenedorServicioMenuItem = new javax.swing.JMenuItem("Mantenedor Servicios");
mantenedorClienteMenuItem = new javax.swing.JMenuItem("Mantenedor Cliente");
ayudaMenu = new javax.swing.JMenu("ayuda");
aboutMenuItem = new javax.swing.JMenuItem("acerca de");


peluqueriaMenu.add(nuevaBoletaMenuItem);
peluqueriaMenu.add(buscarBoletaMenuItem);

menuBar.add(peluqueriaMenu);
inventarioMenu.add(mantenedorServicioMenuItem);
inventarioMenu.add(mantenedorClienteMenuItem);
menuBar.add(inventarioMenu);
ayudaMenu.add(aboutMenuItem);
menuBar.add(ayudaMenu);
setJMenuBar(menuBar);
peluqueriaMenu.add(exitMenuItem);


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jDesktopPane1.setBackground(new java.awt.Color(204, 255, 204));



exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitMenuItemActionPerformed(evt);
}
});

nuevaBoletaMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nuevaBoletaMenuItemActionPerformed(evt);
}
});

buscarBoletaMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buscarBoletaMenuItemActionPerformed(evt);
}
});




aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aboutMenuItemActionPerformed(evt);
}
});


mantenedorServicioMenuItem.addActionListener(new java.awt.event.ActionListener() {
	public void actionPerformed(java.awt.event.ActionEvent evt) {
	mantenedorServicioActionPerformed(evt);
	}
	});

mantenedorClienteMenuItem.addActionListener(new java.awt.event.ActionListener() {
	public void actionPerformed(java.awt.event.ActionEvent evt) {
	mantenedorClienteActionPerformed(evt);
	}
	});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1333, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 13434, javax.swing.GroupLayout.PREFERRED_SIZE)
);




pack();
}

	private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {

		Frame frame = JOptionPane.getFrameForComponent(this);
		AcercaDe acercaDe = new AcercaDe(frame, true);
		acercaDe.setVisible(true);

	}

		
	private void nuevaBoletaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {

		Boleta mantenedor;
		try {
			mantenedor = Boleta.getInstance();
			try {
				mantenedor.limpiarFormulario();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			PeluqueriaApp.jDesktopPane1.removeAll();
			PeluqueriaApp.jDesktopPane1.add(mantenedor);
			mantenedor.setMaximum(true);
			mantenedor.setVisible(true);
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	private void buscarBoletaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {

		BuscarBoletaForm mantenedor;
		try {
			mantenedor = BuscarBoletaForm.getInstance();
			mantenedor.limpiarTabla();
			PeluqueriaApp.jDesktopPane1.removeAll();
			PeluqueriaApp.jDesktopPane1.add(mantenedor);
			mantenedor.setMaximum(true);
			mantenedor.setVisible(true);
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	private void mantenedorServicioActionPerformed(java.awt.event.ActionEvent evt) {

		MantenedorServiciosForm mantenedor;
		try {
			mantenedor = MantenedorServiciosForm.getInstance();
			mantenedor.limpiarFormulario();
			PeluqueriaApp.jDesktopPane1.removeAll();
			PeluqueriaApp.jDesktopPane1.add(mantenedor);
			mantenedor.setMaximum(true);
			mantenedor.setVisible(true);
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	public void mantenedorClienteActionPerformed(java.awt.event.ActionEvent evt) {
		
		MantenedorClienteForm mantenedor;
		try {
			mantenedor = MantenedorClienteForm.getInstance();
			mantenedor.limpiarFormulario();
			PeluqueriaApp.jDesktopPane1.removeAll();
			PeluqueriaApp.jDesktopPane1.add(mantenedor);
			mantenedor.setMaximum(true);
			mantenedor.setVisible(true);
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
		System.exit(0);
	}

	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new PeluqueriaApp().setVisible(true);
			}
		});
	}
	
}